package com.weblog.user.client.factory;


import com.weblog.user.client.ArticleClient;
import com.weblog.user.client.impl.ArticleClientImpl;
import entity.Result;
import entity.StatusCode;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author MaoLin Wang
 * @date 2019/10/2010:37
 */
@Component
public class ArticleFallBackFactory implements FallbackFactory<ArticleClient> {
    @Override
    public ArticleClient create(Throwable throwable) {
        System.out.println("用户服务调用文章客户端出错 :"+throwable.getMessage()==null?"":throwable.getMessage());
        throwable.printStackTrace();
        return new ArticleClientImpl() {
            @Override
            public Result cucArticle(List<String> aids) {
                return new Result(false, StatusCode.ERROR,"用户服务调用文章客户端出错 method：cucArticle");
            }

        };
    }
}
